package com.websocet.config;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * Minio文件上传配置文件
 */
@Component
public class MinioConfig implements InitializingBean {

    public static String MINIO_URL;
    public static String MINIO_NAME;
    public static String MINIO_PASS;
    public static String BUCKET_NAME;

    @Value(value = "${minio.minio_url}")
    private String minioUrl;
    @Value(value = "${minio.minio_name}")
    private String minioName;
    @Value(value = "${minio.minio_pass}")
    private String minioPass;
    @Value(value = "${minio.bucketName}")
    private String bucketName;

    @Override
    public void afterPropertiesSet() throws Exception {
        if(!minioUrl.startsWith("http")){
            minioUrl = "http://" + minioUrl;
        }
        if(!minioUrl.endsWith("/")){
            minioUrl = minioUrl.concat("/");
        }
        MINIO_URL = minioUrl;
        MINIO_NAME = minioName;
        MINIO_PASS = minioPass;
        BUCKET_NAME = bucketName;
    }
}
